package itheima.mocc.MyReflect3;

import java.lang.reflect.Constructor;

public class ConstructorDemo1 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException {
        Class clazz = Class.forName("itheima.mocc.MyReflect3.Student");

//        method1(clazz);

//        method2(clazz);


        Constructor declaredConstructor = clazz.getDeclaredConstructor(String.class);
        System.out.println(declaredConstructor);

        Constructor constructor = clazz.getConstructor(String.class,int.class);
        System.out.println(constructor);
    }

    private static void method2(Class clazz) {
        Constructor[] declaredConstructors = clazz.getDeclaredConstructors();
        for (Constructor declaredConstructor : declaredConstructors) {
            System.out.println(declaredConstructor);
        }
    }

    private static void method1(Class clazz) {
        Constructor[] constructors = clazz.getConstructors();
        for (Constructor constructor : constructors) {
            System.out.println(constructor);
        }
    }
}
